package org.explore.miracle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;
import android.util.Log;

import org.explore.miracle.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    private final String TAG = "------------------->";
    private MainViewModel mainViewModel;
    private ActivityMainBinding data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);
        data = DataBindingUtil.setContentView(this, R.layout.activity_main);
        mainViewModel = new ViewModelProvider(this).get(MainViewModel.class);
        mainViewModel.getUsername().observe(this,s -> data.editTextTextPersonName.setText(s));
        data.setData(mainViewModel);
        data.setLifecycleOwner(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: ");
    }
}